//
//  MyReleaseChangeInfo.m
//  HappyStore
//
//  Created by 李小辉 on 16/6/22.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "MyReleaseChangeInfo.h"
#import "SearchProjectCell.h"
#import "SearchPriceCell.h"
#import "BusinessActCell.h"
#import "RecruitmentShowCell.h"
#import "UsedTool.h"
#import "SoftwareCell.h"
#import "serviceInfo.h"
#import "SoftEnterpriseCell.h"
#import "SearchProjectInfoVC.h"
#import "SearchPriceDetail.h"
#import "BusinessActInfo.h"
#import "RecruitmentInfo.h"
@interface MyReleaseChangeInfo ()

@property (assign, nonatomic) NSInteger paggge;
@property (strong, nonatomic) NSMutableArray *muAryData;
@end

static NSString * SearchProjectcell = @"SearchProjectCell";
static NSString * SearchPricecell = @"SearchPriceCell";
static NSString * BusinessActcell = @"BusinessActCell";
static NSString * Recruitmentcell = @"RecruitmentCell";
static NSString * Softwarecell = @"SoftwareCell";
static NSString * SoftEnterprisecell = @"SoftEnterpriseCell";

@implementation MyReleaseChangeInfo


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBarHidden = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"白色背景"] forBarMetrics:UIBarMetricsDefault];
    //找出导航栏的下边的黑线
    UIImageView *navBarHairlineImageView = [NaviBarLine findHairlineImageViewUnder:self.navigationController.navigationBar];
    navBarHairlineImageView.hidden = NO;
    
    
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 190, 44)];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.font = [UIFont systemFontOfSize:19];
    titleLabel.text = self.titleStr;
    titleLabel.textColor = RGB(45, 45, 45);
    titleLabel.textAlignment = NSTextAlignmentCenter;
    self.navigationItem.titleView = titleLabel;
    
    //设置返回按钮
    UIBarButtonItem *leftItem = [UIBarButtonItem itemWithTarget:self action:@selector(leftBarButtonItemClick) image:@"返回" highImage:@"返回"];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    
    //注册
    UINib * nib = [UINib nibWithNibName:@"SearchProjectCell" bundle:nil];//项目
    
    [self.tableView registerNib:nib forCellReuseIdentifier:SearchProjectcell];
    
    UINib * nib1 = [UINib nibWithNibName:@"SearchPriceCell" bundle:nil];//资金
    
    [self.tableView registerNib:nib1 forCellReuseIdentifier:SearchPricecell];
    
    UINib * nib2 = [UINib nibWithNibName:@"BusinessActCell" bundle:nil];//活动
    
    [self.tableView registerNib:nib2 forCellReuseIdentifier:BusinessActcell];
    
    UINib * nib3 = [UINib nibWithNibName:@"SoftwareCell" bundle:nil];//服务
    
    [self.tableView registerNib:nib3 forCellReuseIdentifier:Softwarecell];
    
    UINib * nib4 = [UINib nibWithNibName:@"SoftEnterpriseCell" bundle:nil];//服务
    
    [self.tableView registerNib:nib4 forCellReuseIdentifier:SoftEnterprisecell];
    
    UINib * nib5 = [UINib nibWithNibName:@"RecruitmentShowCell" bundle:nil];//招聘
    
    [self.tableView registerNib:nib5 forCellReuseIdentifier:Recruitmentcell];
    
    
    
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        self.paggge += 1;
        [self startSearch];
    }];
    self.tableView.mj_footer.hidden = YES;
    
    self.paggge = 1;
    [self startSearch];
    //去掉多余的表格线
    [self setExtraCellLineHidden:self.tableView];
    
    //开启侧滑
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
-(void)leftBarButtonItemClick{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)setExtraCellLineHidden:(UITableView *)tableView{
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor clearColor];
    [tableView setTableFooterView:view];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    [tableView tableViewDisplayWitMsg:@"没有查询到相对应的数据" ifNecessaryForRowCount:self.muAryData.count];
    return self.muAryData.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([self.titleStr isEqualToString:@"项目"]) {//项目
        return 103;
    }
    if ([self.titleStr isEqualToString:@"资金"]) {//资金
        return 145;
    }
    if ([self.titleStr isEqualToString:@"服务"]) {//服务
        return 142;
    }
    if ([self.titleStr isEqualToString:@"招聘"]) {//招聘
        return 110;
    }
    if ([self.titleStr isEqualToString:@"活动"]) {//活动
        return 157;
    }
    else
        return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([self.titleStr isEqualToString:@"项目"]) {
        SearchProjectCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
        tableView.rowHeight = UITableViewAutomaticDimension;
        
        cell.TitleLabel.text = self.muAryData[indexPath.row][@"title"];
        
        cell.AddressLabel.text = self.muAryData[indexPath.row][@"address"];
        
        cell.IndustryLabel.text = self.muAryData[indexPath.row][@"industry"];
        cell.PriceLabel.text = [self comperNumber:self.muAryData[indexPath.row][@"investment"]];
        if ([[self comperNumber:self.muAryData[indexPath.row][@"investment"]] isEqualToString:@"0.00元"]) {
            cell.PriceLabel.text = @"面议";
        }else{
            cell.PriceLabel.text = [self comperNumber:self.muAryData[indexPath.row][@"investment"]];
        }
        if ([self.muAryData[indexPath.row][@"type"] isEqualToString:@"政府"]) {
            
            cell.ProjectIconImageView.image = [UIImage imageNamed:@"政府"];
        }else if ([self.muAryData[indexPath.row][@"type"] isEqualToString:@"企业"]){
            
            cell.ProjectIconImageView.image = [UIImage imageNamed:@"企业"];
        }else{
            
            cell.ProjectIconImageView.image = [UIImage imageNamed:@"个人"];
        }
        //添加审核标签
        [self examineAndVerifyIsShow:self.muAryData[indexPath.row][@"isShow"] andCell:cell];
        
        return cell;
        
    }else if ([self.titleStr isEqualToString:@"资金"]){
        SearchPriceCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchPricecell];
        
        NSDictionary *dic = self.muAryData[indexPath.row];
        
        //设置圆形头像
        [cell.headPhoto.layer setCornerRadius:cell.headPhoto.frame.size.height/2];
        [cell.headPhoto.layer setMasksToBounds:YES];
        [cell.headPhoto setContentMode:UIViewContentModeScaleAspectFill];
        [cell.headPhoto setClipsToBounds:YES];
        cell.headPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
        cell.headPhoto.layer.shadowOffset = CGSizeMake(4, 4);
        cell.headPhoto.layer.shadowOpacity = 0.5;
        cell.headPhoto.layer.shadowRadius = 2.0;
        cell.headPhoto.userInteractionEnabled = YES;
        
        [cell.headPhoto sd_setImageWithURL:self.muAryData[indexPath.row][@"headPhoto"] placeholderImage:[UIImage imageNamed:@"20100403114758394_4147"]];
        
        //添加审核标签
        [self examineAndVerifyIsShow:self.muAryData[indexPath.row][@"isShow"] andCell:cell];
        
        
        if (dic[@"username"]==nil || [dic[@"username"] isEqualToString:@""] || [dic[@"username"] isEqualToString:@"null"]) {
            cell.commentUserName.text = self.muAryData[indexPath.row][@"account"];
        }else{
            cell.commentUserName.text = dic[@"username"];
        }
        
        
        cell.posiTion.text = dic[@"posiTionName"];
        if (dic[@"posiTionName"]==nil||[dic[@"posiTionName"] isEqualToString:@"null"]) {
            cell.posiTion.text = @"";
        }
        
//        if ([dic[@"authState"] integerValue] == 2) {
//            
//            cell.authStateImageView.image = [UIImage imageNamed:@"yirenzheng"];
//        }else{
//            
//            cell.authStateImageView.image = [UIImage imageNamed:@"weirenzheng"];
//        }
        //认证
        cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dic[@"authState"]];
        //会员图标
        cell.authStateImageView.image = [UsedTool setVipimage:dic[@"vipLevel"]];
        cell.titleLabel.text = dic[@"title"];
        
        cell.priceLabel.text = [self comperNumber:dic[@"investment"]];
        
        //判断上级
        cell.companyUserName.text = [UsedTool userType:dic[@"userType"] companyName:dic[@"companyName"] userAddress:dic[@"userAddress"]];

        
        return cell;
        
    }else if ([self.titleStr isEqualToString:@"活动"]){
        
        BusinessActCell *cell = [tableView dequeueReusableCellWithIdentifier:BusinessActcell];
        
        NSDictionary *dicData = [NSDictionary dictionaryWithDictionary:self.muAryData[indexPath.row]];
        
        [cell.photoImageView sd_setImageWithURL:[NSURL URLWithString:dicData[@"logo"]] placeholderImage:[UIImage imageNamed:@"img_normal3"]];
        cell.titleLabel.text = dicData[@"title"];
        cell.addressLabel.text = dicData[@"address"];
        //时间
        NSString *timeStr = dicData[@"createtime"];
        //年月日
        NSString *yearStr = [timeStr substringToIndex:10];
        //几点
        NSString *timeString = [timeStr substringWithRange:NSMakeRange(10,6)];
        //周几
        NSString *weekStr = [UsedTool getWeekDayForstring:timeStr];
        
        cell.timeLabel.text = [NSString stringWithFormat:@"%@ %@ %@",yearStr,weekStr,timeString];
        //标签
        NSArray *arrayLabel = [dicData[@"lable"] componentsSeparatedByString:@","];
        if (arrayLabel.count>0) {
            
            cell.labelLabel.layer.borderWidth = 0.5f;
            cell.labelLabel.layer.borderColor = RGB(23, 176, 216).CGColor;
            cell.labelLabel.backgroundColor = RGB(217, 242, 255);
            cell.labelLabel.text = arrayLabel[0];
            CGSize size = [cell.labelLabel sizeThatFits:CGSizeMake(MAXFLOAT, 18)];
            cell.labelWidthConstraint.constant = size.width +10;
            
        }
        if (arrayLabel.count>1) {
            cell.labelLabelTwo.layer.borderWidth = 0.5f;
            cell.labelLabelTwo.layer.borderColor = RGB(23, 176, 216).CGColor;
            cell.labelLabelTwo.backgroundColor = RGB(217, 242, 255);
            cell.labelLabelTwo.text = arrayLabel[1];
            CGSize sizeTwo = [cell.labelLabelTwo sizeThatFits:CGSizeMake(MAXFLOAT, 18)];
            cell.labelWidthConstraintTwo.constant = sizeTwo.width +10;
        }
        if (arrayLabel.count==1) {
            cell.labelLabelTwo.text = @"";
            cell.labelWidthConstraintTwo.constant = 0;
        }
        
        //添加审核标签
        [self examineAndVerifyIsShow:self.muAryData[indexPath.row][@"isShow"] andCell:cell];
        return cell;
    }else if ([self.titleStr isEqualToString:@"服务"]){
        NSDictionary *dicData = self.muAryData[indexPath.row];
        
        if ([dicData[@"userType"] integerValue] == 2) {
            
            //企业
            static NSString * cellId = @"serviceCellID";
            SoftEnterpriseCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
            if (!cell) {
                cell = [[SoftEnterpriseCell alloc] init];
            }
            cell.titleLabel.text = dicData[@"title"];
            //设置圆形头像
            [cell.headPhoto.layer setCornerRadius:cell.headPhoto.frame.size.height/2];
            [cell.headPhoto.layer setMasksToBounds:YES];
            [cell.headPhoto setContentMode:UIViewContentModeScaleAspectFill];
            [cell.headPhoto setClipsToBounds:YES];
            cell.headPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
            cell.headPhoto.layer.shadowOffset = CGSizeMake(4, 4);
            cell.headPhoto.layer.shadowOpacity = 0.5;
            cell.headPhoto.layer.shadowRadius = 2.0;
            cell.headPhoto.userInteractionEnabled = YES;
            [cell.headPhoto sd_setImageWithURL:dicData[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"project_detail_taoxin_normal"]];
            
            cell.addressLabel.text = dicData[@"address"];
            
            
            //自定义的label
            UILabel *label = [[UILabel alloc] init];
            if (dicData[@"userName"] == nil ||[dicData[@"userName"] isEqualToString:@""]||[dicData[@"userName"] isEqualToString:@"null"]) {
                label.text = dicData[@"account"];
            }else{
                label.text = dicData[@"userName"];
            }
            label.numberOfLines = 1;
            label.font = [UIFont systemFontOfSize:17];
            label.textColor = cell.companyName.textColor;
            CGSize size = [label.text sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(MAXFLOAT, 21)];
            if (size.width > screenW-140) {
                size.width = screenW-140;
            }
            
            CGRect frameC = cell.companyName.frame;
            frameC.size.width = size.width;
            label.frame = frameC;
            [cell addSubview:label];
            
            UIImageView *authImageView = [[UIImageView alloc] initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width+8, label.frame.origin.y+3, 15, 15)];
            
            
//            if ([dicData[@"authState"] integerValue] == 2) {
//                //已认证
//                authImageView.image = [UIImage imageNamed:@"yirenzheng"];
//            }else{
//                
//                authImageView.image = [UIImage imageNamed:@"weirenzheng"];
//            }
            //认证
            cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dicData[@"authState"]];
            //会员图标
            authImageView.image = [UsedTool setVipimage:dicData[@"vipLevel"]];
            [cell addSubview:authImageView];
            //添加审核标签
            [self examineAndVerifyIsShow:self.muAryData[indexPath.row][@"isShow"] andCell:cell];
            return cell;
        }else{
            
            //个人
            static NSString *cellIdentifier = @"serviceCell";
            SoftwareCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
            if (!cell) {
                cell = [[SoftwareCell alloc] init];
            }
            
            NSDictionary *dicData = self.muAryData[indexPath.row];
            cell.titleLabel.text =dicData[@"title"];
            
            
            //设置圆形头像
            [cell.headPhotoImageView.layer setCornerRadius:cell.headPhotoImageView.frame.size.height/2];
            [cell.headPhotoImageView.layer setMasksToBounds:YES];
            [cell.headPhotoImageView setContentMode:UIViewContentModeScaleAspectFill];
            [cell.headPhotoImageView setClipsToBounds:YES];
            cell.headPhotoImageView.layer.shadowColor = [UIColor blackColor].CGColor;
            cell.headPhotoImageView.layer.shadowOffset = CGSizeMake(4, 4);
            cell.headPhotoImageView.layer.shadowOpacity = 0.5;
            cell.headPhotoImageView.layer.shadowRadius = 2.0;
            cell.headPhotoImageView.userInteractionEnabled = YES;
            
            [cell.headPhotoImageView sd_setImageWithURL:dicData[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"project_detail_taoxin_normal"]];
            
            if (dicData[@"userName"] == nil ||[dicData[@"userName"] isEqualToString:@""]||[dicData[@"userName"] isEqualToString:@"null"]) {
                cell.commentUserName.text = dicData[@"account"];
            }else{
                cell.commentUserName.text = dicData[@"userName"];
            }
            
            cell.posiTion.text = dicData[@"posiTionName"];
            if (dicData[@"posiTionName"]==nil||[dicData[@"posiTionName"] isEqualToString:@"null"]) {
                cell.posiTion.text = @"";
            }
            
//            if ([dicData[@"authState"] integerValue] == 2) {
//                
//                cell.authStateImageView.image = [UIImage imageNamed:@"yirenzheng"];
//            }else{
//                
//                cell.authStateImageView.image = [UIImage imageNamed:@"weirenzheng"];
//            }
            //认证
            cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dicData[@"authState"]];
            //会员图标
            cell.authStateImageView.image = [UsedTool setVipimage:dicData[@"vipLevel"]];
            //判断上级
            cell.companyUserName.text = [UsedTool userType:dicData[@"userType"] companyName:dicData[@"companyName"] userAddress:dicData[@"userAddress"]];
            //添加审核标签
            [self examineAndVerifyIsShow:self.muAryData[indexPath.row][@"isShow"] andCell:cell];
            return cell;
        }
        
    }else if ([self.titleStr isEqualToString:@"招聘"]){

        RecruitmentShowCell *cell = [tableView dequeueReusableCellWithIdentifier:Recruitmentcell];

        NSDictionary *dic = [NSDictionary dictionaryWithDictionary:self.muAryData[indexPath.row]];

        cell.titleLabel.text = dic[@"positionName"];
        
        
        
        cell.moneyLabel.text = dic[@"money"];
        if (dic[@"money"]==nil||[dic[@"money"] isEqualToString:@"null"]||[dic[@"money"] isEqualToString:@""]||[dic[@"money"] integerValue]==0) {
            cell.moneyLabel.text = @"面议";
        }
        NSRange range = [dic[@"address"] rangeOfString:@"-"];
        cell.cityLabel.text = [dic[@"address"] substringToIndex:range.location];
        
        cell.schoolLabel.text = dic[@"schooling"];
        cell.yearLabel.text = dic[@"experience"];
        cell.addressLabel.text = dic[@"recruitCompany"];
        return cell;
    }
    else return nil;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    //取消显示后退键文字
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtonItem;
    
    if ([self.titleStr isEqualToString:@"项目"]) {
        if (allConstMemberid) {
            [self showRoundProgressWithTitle:@"请稍后..."];
            
            NSMutableDictionary * dict = [NSMutableDictionary dictionary];
            dict[@"projectId"] = self.muAryData[indexPath.row][@"projectId"];
            dict[@"userId"] = [USER_DEFAULTS objectForKey:@"userid"];
            
            [LSHttpTool sendHttpData:@"projectDetail_app_project.im" params:dict success:^(id responseObject) {
                NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
                
                if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            
                    SearchProjectInfoVC * SeaVC = [[SearchProjectInfoVC alloc]initWithNibName:@"SearchProjectInfoVC" bundle:nil];
                    SeaVC.dataDict = dicInfo[@"data"];
                    
                    SeaVC.projectData = [NSMutableArray arrayWithArray:dicInfo[@"data"][@"commentsList"]];
                    SeaVC.tig = @"project";
                    [self.navigationController pushViewController:SeaVC animated:YES];

                }

                [self hideBubble];
            } failure:^(NSError *error) {

                [self showSingleIconBubble:@"网络连接错误"];
                
            }];
            
        }else{
            
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"请先登录" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"登录", nil];
            
            alert.tag = 10;
            
            [alert show];
            
        }
//        SearchProjectInfoVC * SeaVC = [[SearchProjectInfoVC alloc]initWithNibName:@"SearchProjectInfoVC" bundle:nil];
//        
//        SeaVC.projectId = self.muAryData[indexPath.row][@"projectId"];
//        SeaVC.tig = @"project";
//        [self.navigationController pushViewController:SeaVC animated:YES];
        
    }else if ([self.titleStr isEqualToString:@"资金"]){
        
        if (allConstMemberid) {
            
            //取消显示后退键文字
            UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
            self.navigationItem.backBarButtonItem = barButtonItem;

            [self showRoundProgressWithTitle:@"请稍后..."];
            
            NSMutableDictionary *muDicParameter = [NSMutableDictionary dictionary];
            
            muDicParameter[@"fundsId"] = self.muAryData[indexPath.row][@"fundsId"];
            
            if ([USER_DEFAULTS objectForKey:@"userid"] != nil) {
                
                muDicParameter[@"userId"] = [USER_DEFAULTS objectForKey:@"userid"];
                
            }
            
            NSString *strURL = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"fundsDetail_app_funds.im"];
            AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
            
            [manager POST:strURL parameters:muDicParameter progress:^(NSProgress * _Nonnull uploadProgress) {
                
            } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
                
                [self hideBubble];
                
                if ([dicInfo[@"result"] integerValue] ==1) {
                    
                    SearchPriceDetail *Svc = [[SearchPriceDetail alloc] initWithNibName:@"SearchPriceDetail" bundle:nil];
                    
                    Svc.dicData = dicInfo[@"data"];
                    Svc.commentsList = dicInfo[@"data"][@"commentsList"];
                    Svc.tig = @"price";
                    [self.navigationController pushViewController:Svc animated:YES];
                    
                }
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

                [self showSingleIconBubble:error.localizedDescription];
            }];
            
        }else{
            
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"请先登录" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"登录", nil];
            
            alert.tag = 10;
            
            [alert show];
            
        }

//        SearchPriceDetail *Svc = [[SearchPriceDetail alloc] initWithNibName:@"SearchPriceDetail" bundle:nil];
//        Svc.tig = @"price";
//        Svc.fundsId = self.muAryData[indexPath.row][@"fundsId"];
//        
//        [self.navigationController pushViewController:Svc animated:YES];
        
    }else if ([self.titleStr isEqualToString:@"活动"]){
        BusinessActInfo *businessVC = [[BusinessActInfo alloc] init];
        businessVC.activityId = self.muAryData[indexPath.row][@"activityId"];
        [self.navigationController pushViewController:businessVC animated:YES];
        
    }else if ([self.titleStr isEqualToString:@"服务"]){
        //推出详细界面
        serviceInfo *serviceInfoVC = [[serviceInfo alloc] initWithNibName:@"serviceInfo" bundle:nil];
        serviceInfoVC.tig = @"service";
        serviceInfoVC.serviceId = self.muAryData[indexPath.row][@"serviceId"];
        [self.navigationController pushViewController:serviceInfoVC animated:YES];
        
    }else if ([self.titleStr isEqualToString:@"招聘"]){
        RecruitmentInfo *recruVC = [[RecruitmentInfo alloc] initWithNibName:@"RecruitmentInfo" bundle:nil];
        recruVC.jobId = self.muAryData[indexPath.row][@"jobId"];
        [self.navigationController pushViewController:recruVC animated:YES];
    }

}

#pragma mark - 表格侧滑－－删除

//侧滑－－删除
//先要设Cell可编辑
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
        return YES;

}
//定义编辑样式
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return UITableViewCellEditingStyleDelete;
}


//进入编辑模式，按下出现的编辑按钮后
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [self startDeleteWithId:indexPath];
    
}
//编辑的文字
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
    return @"删除";
}



#pragma mark - 获取数据
- (void)startSearch
{
    
    //token=验证用户&page=页码&userId=用户id
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:[NSString stringWithFormat:@"%ld",self.paggge] forKey:@"page"];
    
    NSString *strURl = @"";
    
    if ([self.titleStr isEqualToString:@"项目"]) {//项目
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutProject_app_myHome.im.lensum"];
    }
    if ([self.titleStr isEqualToString:@"资金"]) {//资金
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutFunds_app_myHome.im.lensum"];
    }
    if ([self.titleStr isEqualToString:@"服务"]) {//服务
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutService_app_myHome.im.lensum"];
    }
    if ([self.titleStr isEqualToString:@"招聘"]) {//招聘
        [muDicParameters setObject:@"1" forKey:@"type"];
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutJobhunting_app_myHome.im.lensum"];
    }
    if ([self.titleStr isEqualToString:@"活动"]) {
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getMyoutActivity_app_myHome.im.lensum"];
    }
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        [self.tableView.mj_header endRefreshing];
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
        NSLog(@"%@",dicInfo);
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            [self.tableView.mj_header endRefreshing];
            if (self.paggge == 1) {
                self.muAryData = [NSMutableArray arrayWithArray:[dicInfo objectForKey:@"data"][@"record"]];
                
                if (self.muAryData.count == 10) {
                    self.tableView.mj_footer.hidden = NO;
                }else {
                    self.tableView.mj_footer.hidden = YES;
                }
                
            }else {
                NSArray *ary11 = [dicInfo objectForKey:@"data"][@"record"];
                for (int i = 0; i<ary11.count; i++) {
                    NSDictionary *dic1 = ary11[i];
                    [self.muAryData addObject:dic1];
                }
                if (ary11.count == 10) {
                    self.tableView.mj_footer.hidden = NO;
                }else {
                    self.tableView.mj_footer.hidden = YES;
                }
                
            }
            
            
            [self.tableView reloadData];

        }else {
            if (self.paggge == 1) {
                self.muAryData = [NSMutableArray array];
            }
            
            [self.tableView reloadData];
            [self.tableView.mj_header endRefreshing];
            [self.tableView.mj_footer endRefreshing];
        }
        
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self.tableView.mj_header endRefreshing];
        [self.tableView.mj_footer endRefreshing];
        if (self.paggge == 1) {
            self.muAryData = [NSMutableArray array];
            [self.tableView reloadData];
        }

        [self showSingleIconBubble:error.localizedDescription];

    }];
}


#pragma mark - 删除数据
- (void)startDeleteWithId:(NSIndexPath *)indexPath
{
    [self showRoundProgressWithTitle:@"删除中..."];
    //token=验证用户&page=页码&userId=用户id
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    
    
    NSString *strURl = @"";
    if ([self.titleStr isEqualToString:@"项目"]) {//项目
        [muDicParameters setObject:self.muAryData[indexPath.row][@"projectId"] forKey:@"projectId"];
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"deleteMyProject_app_myHome.im.lensum"];
    }
    if ([self.titleStr isEqualToString:@"资金"]) {//资金
        [muDicParameters setObject:self.muAryData[indexPath.row][@"fundsId"] forKey:@"fundsId"];
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"deleteMyFunds_app_myHome.im.lensum"];
    }
    if ([self.titleStr isEqualToString:@"服务"]) {//服务
        [muDicParameters setObject:self.muAryData[indexPath.row][@"serviceId"] forKey:@"serviceId"];
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"deleteMyService_app_myHome.im.lensum"];
    }
    if ([self.titleStr isEqualToString:@"招聘"]) {//招聘
        [muDicParameters setObject:@"1" forKey:@"type"];
        [muDicParameters setObject:self.muAryData[indexPath.row][@"jobId"] forKey:@"jobId"];
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"deleteMyJobhunting_app_myHome.im.lensum"];
    }
    if ([self.titleStr isEqualToString:@"活动"]) { //活动
        [muDicParameters setObject:self.muAryData[indexPath.row][@"activityId"] forKey:@"activityId"];
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"deleteMyActivity_app_myHome.im.lensum"];
    }
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            [self.muAryData removeObjectAtIndex:indexPath.row];
            [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

            [self showRightWithTitle:dicInfo[@"msg"] autoCloseTime:2];
        }else {

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
            
        }

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
       [self showSingleIconBubble:error.localizedDescription];

    }];
}

-(void)examineAndVerifyIsShow:(NSString *)isShow andCell:(UITableViewCell *)cell{
    for (UILabel *label in cell.subviews) {
        if (label.tag == 1) {
            [label removeFromSuperview];
            break;
        }
    }
    
    UILabel *isShowLabel = [[UILabel alloc] init];
    isShowLabel.textAlignment = NSTextAlignmentCenter;
    isShowLabel.font = [UIFont systemFontOfSize:16];
    isShowLabel.textColor = [UIColor whiteColor];
    isShowLabel.tag = 1;
    isShowLabel.layer.borderWidth = 0.5f;
    isShowLabel.layer.masksToBounds = YES;
    isShowLabel.layer.cornerRadius = 2.0f;
    //逆时针15度
    isShowLabel.transform=CGAffineTransformMakeRotation(M_PI/6);
    
    if ([isShow integerValue]) {
        isShowLabel.layer.borderColor = RGB(73, 186, 103).CGColor;
        isShowLabel.textColor = RGB(73, 186, 103);
        isShowLabel.backgroundColor = RGB(73, 186, 103);
        isShowLabel.text = @"审核通过";
    }else{
        isShowLabel.layer.borderColor = RGB(255, 155, 0).CGColor;
        isShowLabel.textColor = RGB(255, 155, 0);
        isShowLabel.text = @"审核中";
    }
    [cell addSubview:isShowLabel];
    if ([cell isKindOfClass:[SearchPriceCell class]]) {
        [cell sendSubviewToBack:isShowLabel];
        
        isShowLabel.frame = CGRectMake(cell.centerX - 40, cell.centerY - 4, 80, 8);
    }else{

        isShowLabel.frame = CGRectMake(cell.centerX - 35, cell.centerY - 4, 70, 8);
    }
    //边界修剪
    cell.clipsToBounds = YES;
}

-(NSString *)comperNumber:(NSString *)number
{
    CGFloat num1 = [number floatValue];
    NSString *strNum = @"";
    
    if (num1 >= 100000000) {
        
        strNum = [NSString stringWithFormat:@"%.2f亿元",num1/100000000];
    }else if (num1<100000000 && num1>=10000){
        
        strNum = [NSString stringWithFormat:@"%.2f万元",num1/10000];
    }else{
        
        strNum = [NSString stringWithFormat:@"%.2f元",num1];
    }
    return strNum;
}

@end
